<template>
  <div>
    <!-- 面包屑导航 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>权限管理</el-breadcrumb-item>
      <el-breadcrumb-item>角色列表</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 权限列表 -->
    <el-card>
      <el-table
        style="width: 100%"
        :border="true"
        :stripe="true"
        :data="rightlist"
      >
        <el-table-column label="#" width="50" type="index"> </el-table-column>
        <el-table-column label="权限名称" width="360" prop="authName">
        </el-table-column>
        <el-table-column label="路径" width="360" prop="path">
        </el-table-column>
        <el-table-column label="权限等级" width="360" prop="level">
          <template slot-scope="scope">
            <el-tag :type="tagstyle(scope.row.level)" effect="dark">{{
              tagcontent(scope.row.level)
            }}</el-tag>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      rightlist: [],
    };
  },
  created() {
    this.getrightlist();
  },
  methods: {
    async getrightlist() {
      const { data: res } = await this.$http.get("rights/list");
      console.log(res);
      if (res.meta.status != 200)
        return this.$message.error("获取权限列表失败");
      this.rightlist = res.data;
      // this.$message.success("获取权限列表成功");
    },
    tagstyle(level) {
      if (level == "0") return "";
      else if (level == "1") return "success";
      else if (level == "2") return "warning";
    },
    tagcontent(level) {
      if (level == "0") return "一级权限";
      if (level == "1") return "二级权限";
      if (level == "2") return "三级权限";
    },
  },
};
</script>
<style lang='less' scoped>
</style>